package com.tanxi521.springboot.service.impl;

import com.tanxi521.springboot.mapper.OfficialMessageMapper;
import com.tanxi521.springboot.pojo.OfficialMessage;
import com.tanxi521.springboot.pojo.Page;
import com.tanxi521.springboot.service.OfficialMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class OfficialMessageImpl implements OfficialMessageService {

    @Autowired
    private OfficialMessageMapper officialMessageMapper;

    @Override
    public List<OfficialMessage> queryMessageList(Integer pageSize, Integer pageIndex, OfficialMessage officialMessage) {
        Page page = new Page(pageIndex, pageSize);
        return officialMessageMapper.selectAllOfficialMessage(page, officialMessage);
    }

    @Override
    public int queryMessageCount(OfficialMessage officialMessage) {
        return officialMessageMapper.selectAllMessageCount(officialMessage);
    }

    @Override
    public int insertOfficialMessage(OfficialMessage officialMessage) {
        officialMessage.setCreateTime(new Date());
        return officialMessageMapper.insert(officialMessage);
    }

    @Override
    public int deleteMessageById(List<Integer> ids) {
        return officialMessageMapper.deleteOfficialMessage(ids);
    }
}
